package mgslangpack.dataaccess;

import java.sql.*;
import java.util.ArrayList;

public class DataAccess {
        
        static private DataAccess me;
    
        public static DataAccess getInstance() throws Exception {
        
            if(me == null) {
                me = new DataAccess();
            }
            return me;
        }
        
        private Connection connection;
	
	private DataAccess() throws Exception {
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		connection = DriverManager.getConnection("jdbc:odbc:TheOZ_DB","","");		
	}

	public ResultSet getOrder(int orderId) {
            // TODO: Write get order code
            return null;
	}
	
	public void setOrder(int id, Date orderDate, int customerId, ArrayList orderItems) {
            // TODO: Write set order code
	}
	
	public ResultSet listOrders() {
            // TODO: Write list orders code
            return null;
	}
        
        public void test() {
        
            try {
                // Create a result set
                Statement stmt = connection.createStatement();
                ResultSet rs = stmt.executeQuery("SELECT * FROM Bookings");

                System.out.println("Printing Booking records:");
                while(rs.next()) {

                        System.out.println(
                                "Record " + 
                                rs.getRow() + " " + 
                                rs.getString(1) + " " + 
                                rs.getString(2) + " " + 
                                rs.getString(3)
                        );

                }
			
            } catch (Exception e) {
                    e.printStackTrace();
            }

        }
        
        public static void main(String[] args) {
        
            try {
                DataAccess me = new DataAccess();
                me.test();
            } catch(Exception e) {
                e.printStackTrace();
            }
            
        }
        
        
		
}

